/************************************************************************
                     TMenu 在LVGL实现时的 Demo
主要用于测式lvTMenu系统
 ************************************************************************/
#include "lvgl.h"
#include <string.h>
#include "TMenu.h"

extern void lvTMenu_Demo(void);
//--------------------------重新进入菜单回调实现-------------------------
static void event_cb(lv_event_t * e)
{
  lv_obj_t * mbox = lv_event_get_user_data(e);
  lv_msgbox_close(mbox);
  //lv_msgbox_close_async(mbox);
  lvTMenu_Demo();
}

//--------------------------退出菜单通报函数实现-------------------------
void TMenu_cbExitMenuNotify(void)
{
  LV_LOG_USER("lvTMenu has exited!");
  //提示退出并可重新进入
  lv_obj_t * mbox = lv_msgbox_create(lv_screen_active());
  lv_msgbox_add_text(mbox, "lvTMenu has exited!\n\
                             Please press the confirm button to re-enter");
  lv_obj_t * btn;
  btn = lv_msgbox_add_footer_button(mbox, "Enter");
  lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, mbox);
}

//-----------------------------Demo入口实现-------------------------------
void lvTMenu_Demo(void)
{
  lv_obj_t *pParent = lv_obj_create(lv_screen_active());
  lv_obj_set_size(pParent, lv_pct(100), lv_pct(100));
  lv_obj_center(pParent);
  TMenu_Init(pParent);
}
//---------------------------外界主动删除实现-------------------------------
void lvTMenu_Demo_Delete(void)
{
  TMenu_ExitMenu();
}
